package com.coffeeloversupportlibrary.coffeelover.networktest;

import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.coffeeloversupportlibrary.R;
import com.coffeeloversupportlibrary.coffeelover.domain.article.entity.Article;
import com.coffeeloversupportlibrary.core.base.BaseActivity;
import com.coffeeloversupportlibrary.databinding.ActivityNetBinding;


import java.util.List;

/**
* @date 2021/11/13 15:54
* @params
* @return
* @description TODO RESTFUL  Retrofit  富文本编辑相关网络问题：
 * todo:1.使用post网络请求故障的原因  2.富文本编辑展示图片加载问题 换行符问题  3.retrofit 相关注解
 *
*/

public class NetActivity extends BaseActivity<NetViewModel, ActivityNetBinding> {
    private String contentText;


    @Override
    public void registerUIChangeCallBack() {
        getViewModel().getResponseInfo().observe(this, new Observer<String>() {
            @Override
            public void onChanged(String s) {

                getBinding().info.setText(s);
                contentText=s;
            }
        });

    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_net;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        getBinding().click.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                List<Article> list=getViewModel().articleList();
               if(null!=list){
                   for(Article article:list){
                       Log.e("TAG",article.getArticleId());
                   }
               }
            }
        });
        getBinding().jumb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle=new Bundle();
                bundle.putString("content",contentText);
//                startActivity(ArticleDetails.class,bundle);
            }
        });

    }
}